﻿/// <reference path="../Ref/jquery-1.7.2-vsdoc.js" />
/// <reference path="wme.layout.js" />

//Default jQuery settings
$.fx.speeds._default = 100;

/* Custom jQuery extensions
/---------------------------------------*/
$.fn.blink = function (interval) {
    //Default blinking every 1sec
    if (interval == undefined) interval = 1000;
    var _this = $(this);
    _this.fadeOut(interval, function () {
        _this.fadeIn(interval, function () {
            _this.blink(interval);
        });
    });
};

/* Core WME js
/---------------------------------------*/
var wmeCore = function () {
    var themeBackground = '#0094FF';
    var themeForeground = '#FFFFFF';
    var animationSpeed = 200;

    init = function () {
        //Init layout
        wmeLayout.init();

        //Button function
        $('.wme-button').hover(
            function () {
                $(this).stop().animate({ opacity: 0.5 }, 200);
            },
            function () {
                $(this).stop().animate({ opacity: 1 }, 200);
            }
        );

        //Init theme
        setThemeColor(themeBackground, themeForeground);

        //Window resize
        $(window).bind(
			'resize',
			function () {
			    //Reinitialise side bar scrolling
			    $('.wme-layout-sidebar-content').data('jsp').reinitialise();
			}
		);
    };

    //animationSpeed = function () { return animationSpeed; }

    setThemeColor = function (back, fore) {
        if (back !== undefined && back !== null) themeBackground = back;
        if (fore !== undefined && fore !== null) themeForeground = fore;
        $('.wme-theme').css({ 'background': themeBackground, 'color': themeForeground });
    };

    foreColor = function () { return themeForeground; }
    backColor = function () { return themeBackground; }
    return {
        init: init,
        setThemeColor: setThemeColor,
        foreColor: foreColor,
        backColor: backColor,
        animationSpeed : animationSpeed
    }
} ();